package com.mushuroom.live;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMessage;
import org.springframework.http.converter.HttpMessageConverter;

import java.util.stream.Collector;
//qwdwdawd
import java.util.stream.Collectors;

@SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient
@MapperScan("com.mushuroom.live.dao")
public class LiveApplication {
    public static void main(String[] args) {
        SpringApplication.run(LiveApplication.class,args);}
        @Bean
        @ConditionalOnMissingBean
        //它是修饰bean的一个注解，主要实现的是，当你的bean被注册之后，
        // 如果而注册相同类型的bean，就不会成功，它会保证你的bean只有一个，即你的实例只有一个，
        // 当你注册多个相同的bean时，会出现异常.
        public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters){
            return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList()));
        }


}
